 <!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>二分查找</title>
	<script>
		function binarySearch(arr, value) {
			var min = 0, max = arr.length - 1;
			var index = -1;
			while(min <= max){
				// debugger;
				var m = parseInt((min + max) / 2);
				// console.log("m",m)
				if(arr[m] == value){
					index = m;
					break;
				}else if(arr[m] > value){
					max = m - 1;
				}else {
					min = m + 1;
				}
			}
			// console.log("min %d, max %d, index %d", min, max, m);
			return m;
		}
		var arr = [1,4,7,10,12,34,56];
		var index = binarySearch(arr, 11);
		for(var i = 0; i < index; i++) {
			var j = i + 1;
			for(; j < index; j++) {
				if(arr[i] + arr[j] == 11) {
					console.log("find i=%d, j=%d", arr[i], arr[j]);
					break;
				}
			}
		}
		// if(index >= 0) {
		// 	console.log("find index: %d, value: %d", index, arr[index]);
		// }else{
		// 	console.log("not find");
		// }

		var obj = null;
		var s  = !obj;
		console.log(s);
		console.log(!undefined);
	</script>
</head>
<body>
	
</body>
</html>